<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../css/bootstrap.min.css">
</head>
<body style="background-color: #F5F6F7">
<div class="container" style="background-color:white;margin-top: 20px">
    <form id="form" style="margin:10px 0px 10px">
        <span style="font-size:larger;color: black">修改快递员</span>
        <hr style="border: black 1px solid">
        <div class="form-group">
            <label for="courierPhone">电话号</label>
            <input id="courierPhone" type="text" class="form-control" name="courierPhone" id="courierPhone" placeholder="请输入电话号">
        </div>
        <button id="find"  type="button" class="btn btn-danger form-control ">查询</button>
        <div id="success" >
            <div class="form-group">
                <label for="courierName">姓名</label>
                <input type="text" class="form-control" name="courierName" id="courierName" placeholder="请输入姓名">
            </div>
            <div data-toggle="distpicker" class="form-group">
                <label>地址 :</label>
                <select name="courierProvince"></select>
                <select name="courierCity"></select>
                <select name="courierArea"></select>
            </div>
            <div class="form-group">
                <label>性别 :</label>
                <label class="radio-inline">
                    <input type="radio" name="sex" value="man">男
                </label>
                <label class="radio-inline">
                    <input type="radio" name="sex" value="woman">女
                </label>
            </div>
            <div class="form-group">
                <label for="IdCard">身份证号</label>
                <input type="text" class="form-control" name="IdCard" id="IdCard" placeholder="请输入身份证号">
            </div>
            <div class="form-group">
                <label for="siteId">所属站点ID</label>
                <input type="text" class="form-control" name="siteId" id="siteId" placeholder="请输入所属站点ID">
            </div>
            <div class="form-group">
                <label>权限 :</label>
                <select name="rights" id="rights">
                    <option>请选择权限</option>
                    <option name="rights0" value="zero">用户</option>
                    <option name="rights1" value="one">快递员</option>
                    <option name="rights2" value="two">管理员</option>
                </select>
            </div>
            <button id="update" type="submit" class="btn btn-danger form-control ">修改</button>
        </div>
    </form>
</div>
<script src="../js/jquery-3.3.1.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/distpicker.data.js"></script>
<script src="../js/distpicker.js"></script>
<script src="../layer/layer.js"></script>
<script>
    $(function(){
        $("#success").hide();
        $("#find").click(function(){
            var courierPhone = $("#courierPhone").val();
            $.getJSON("../adminSelectCourier.do",{courierPhone:courierPhone},function(data){
                console.log(data)
                layer.msg(data.message);
                if(data.message == "查询成功"){
                    $("#success").show();
                    $("#find").hide();
                }
                $("#courierPassword").val("");
                $("#IdCard").val(data.data[0].idCard);
                $("#courierName").val(data.data[0].courierName);
                $("#siteId").val(data.data[0].siteId);
            })
        });

        $("#form").submit(function(){
            console.log("123")
            let courierNum = $("#courierNum").val();
            let courierPhone = $("#courierPhone").val();
            let courierName = $("#courierName").val();
            let IdCard = $("#IdCard").val();
            let siteId = $("#siteId").val();
            $.post("../adminUpdateCourier.do",{
                courierNum:courierNum,
                courierPhone:courierPhone,
                courierName:courierName,
                IdCard:IdCard,
                siteId:siteId
            },function(data){
                //layer.msg(data.data.message);
                console.log(data)
                if(data.code == 1){
                    //录入成功
                    layer.msg("修改成功");
                    $("input").val("");
                    // $("input:eq(1)").val("顺丰速运");
                }else{
                    layer.msg("修改失败");
                    //录入失败
                }
            });
            return false
        });
    });
</script>


</body>
</html>